USE [BDCLINICA]
GO

/****** Object:  Table [dbo].[CA_CIERRE]    Script Date: 01/21/2014 22:28:01 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[CA_CIERRE](
	[idCierreCaja] [int] NOT NULL,
	[idPuntoVenta] [int] NULL,
	[feFechaCierre] [datetime] NULL,
	[idPersonalApertura] [int] NULL,
	[fecReg] [datetime] NULL,
	[idArqueo] [int] NULL,
	[idPersonalCierre] [int] NULL,
 CONSTRAINT [PK_CA_CIERRE] PRIMARY KEY CLUSTERED 
(
	[idCierreCaja] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[CA_CIERRE]  WITH CHECK ADD  CONSTRAINT [fk_CA_CIERRE_CA_ARQUEO] FOREIGN KEY([idArqueo])
REFERENCES [dbo].[CA_ARQUEO] ([idArqueo])
GO

ALTER TABLE [dbo].[CA_CIERRE] CHECK CONSTRAINT [fk_CA_CIERRE_CA_ARQUEO]
GO

ALTER TABLE [dbo].[CA_CIERRE]  WITH CHECK ADD  CONSTRAINT [fk_CA_CIERRE_CA_PUNTOVENTA] FOREIGN KEY([idPuntoVenta])
REFERENCES [dbo].[CA_PUNTOVENTA] ([idPuntoVenta])
GO

ALTER TABLE [dbo].[CA_CIERRE] CHECK CONSTRAINT [fk_CA_CIERRE_CA_PUNTOVENTA]
GO


USE [BDCLINICA]
GO

/****** Object:  Table [dbo].[CA_NOTA_DEBITO]    Script Date: 01/21/2014 22:31:28 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[CA_NOTA_DEBITO](
	[idNotaDebito] [int] NOT NULL,
	[idCierreCaja] [int] NULL,
	[idTipoDiferencia] [int] NULL,
	[numMonto] [decimal](15, 2) NULL,
	[txtObservacion] [varchar](300) NULL,
 CONSTRAINT [PK_CA_NOTA_DEBITO] PRIMARY KEY CLUSTERED 
(
	[idNotaDebito] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[CA_NOTA_DEBITO]  WITH CHECK ADD  CONSTRAINT [fk_CA_NOTA_DEBITO_CA_CIERRE] FOREIGN KEY([idCierreCaja])
REFERENCES [dbo].[CA_CIERRE] ([idCierreCaja])
GO

ALTER TABLE [dbo].[CA_NOTA_DEBITO] CHECK CONSTRAINT [fk_CA_NOTA_DEBITO_CA_CIERRE]
GO


INSERT INTO [BDCLINICA].[dbo].[CA_PUNTOVENTA]
           ([idPuntoVenta]
           ,[txtDescripcion]
           ,[fecReg]
           ,[idUsuario])
SELECT 1,'CAJA 1',GETDATE(),'ADMIN'
UNION 
SELECT 2,'CAJA 2',GETDATE(),'ADMIN'    
GO

ALTER TABLE [BDCLINICA].[dbo].[CA_MONEDA]
ADD txtAbreviatura varchar(50)
go

INSERT INTO [BDCLINICA].[dbo].[CA_MONEDA]
           ([idMoneda]
           ,[txtNombreMoneda],[txtAbreviatura])
select 1,'NUEVOS SOLES','S/.'
UNION
SELECT 2,'DOLARES','USD $'
GO



INSERT INTO [BDCLINICA].[dbo].[CA_ARQUEO]
           ([idArqueo]
           ,[idCajero]
           ,[fecFechaArqueo]
           ,[horaArqueo]
           ,[fecFechaReg]
           ,[idPuntoVenta]
           ,[numImporteTotal])
select 1,1,getdate(),getdate(),getdate(),1,300
GO

INSERT INTO [BDCLINICA].[dbo].[CA_DETALLEARQUEO]
           ([idArqueo]
           ,[idDetalle]
           ,[idMoneda]
           ,[idDenominacion]
           ,[numCantidad])
select 1,1,1,100,3
GO






INSERT INTO [BDCLINICA].[dbo].[CA_CIERRE]
           ([idCierreCaja]
           ,[idPuntoVenta]
           ,[feFechaCierre]
           ,[idPersonalApertura]
           ,[fecReg]
           ,[idArqueo]
           ,[idPersonalCierre])

select 1,1,getdate(),1,getdate(),1,1           

GO


